package com.crm.dao;

import java.util.List;

import org.springframework.orm.hibernate5.support.HibernateDaoSupport;

import com.crm.entity.User;

public class UserDao extends HibernateDaoSupport{

	public User login(User user) {
		List<User> list = (List<User>) this.getHibernateTemplate().find("from User where username = ? and password = ?", user.getUsername(),user.getPassword());
		if(list!=null && list.size()!=0){
			return list.get(0);
		}
		return null;
	}

	public List<User> findAllUser() {
		return (List<User>) this.getHibernateTemplate().find("From User");
	}

}
